
package se.sll.service.catalogue.capacity.api.resource;

import java.util.List;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
import se.sll.service.catalogue.capacity.api.model.CareUnit;
import se.sll.service.catalogue.capacity.api.model.CareUnitRefList;
import se.sll.service.catalogue.capacity.api.model.ServiceException;
import se.sll.service.catalogue.capacity.api.model.UnitIds;
import se.sll.service.catalogue.capacity.api.model.UnitList;


/**
 * Service for creating, updating, reading capacities.
 * 
 */
@Path("capacity")
public interface CapacityService {


    /**
     * Get all stored capacities, grouped by Care Units and Products
     * 
     */
    @GET
    @Produces({
        "application/json"
    })
    CapacityService.GetCapacityResponse getCapacity()
        throws Exception
    ;

    /**
     * Create a new capacity
     * 
     * @param entity
     *      e.g. {
     *       "hsaID" : "SE2321000016-1HF3",
     *       "product" : "???",
     *       "code" : "1",
     *       "codeSystem" : "oid.sll.vantetider",
     *       "value" : "18",
     *       "validTo" : "1427410800000"
     *     }
     *     
     */
    @POST
    @Consumes("application/json")
    CapacityService.PostCapacityResponse postCapacity(CareUnit entity)
        throws Exception
    ;

    /**
     * Update a capacity
     * 
     * @param entity
     *      e.g. {
     *       "hsaID" : "SE2321000016-1HF3",
     *       "product" : "???",
     *       "code" : "1",
     *       "codeSystem" : "oid.sll.vantetider",
     *       "value" : "18",
     *       "validTo" : "1427410800000"
     *     }
     *     
     */
    @PUT
    @Consumes("application/json")
    CapacityService.PutCapacityResponse putCapacity(CareUnit entity)
        throws Exception
    ;

    /**
     * 
     * @param entity
     *      e.g. {
     *         "units": [
     *             {
     *                 "unitId": "SE2321000016-14VK"
     *             },
     *             {
     *                 "unitId": "SE2321000016-3M0N"
     *             }
     *         ]
     *     }
     *     
     */
    @POST
    @Path("byunitids")
    @Consumes("application/json")
    @Produces({
        "application/json"
    })
    CapacityService.PostCapacityByunitidsResponse postCapacityByunitids(UnitList entity)
        throws Exception
    ;

    /**
     * Reads all capacities belonging to a specific Care Unit
     * 
     * @param hsaId
     *     
     */
    @GET
    @Path("{hsaId}")
    @Produces({
        "application/json"
    })
    CapacityService.GetCapacityByHsaIdResponse getCapacityByHsaId(
        @PathParam("hsaId")
        String hsaId)
        throws Exception
    ;

    /**
     * Delete capacities for a specific combination of unitId, product and code.
     * 
     * @param product
     *     
     * @param code
     *     
     * @param hsaId
     *     
     */
    @DELETE
    @Path("{hsaId}/{product}/{code}")
    CapacityService.DeleteCapacityByHsaIdByProductByCodeResponse deleteCapacityByHsaIdByProductByCode(
        @PathParam("hsaId")
        String hsaId,
        @PathParam("product")
        String product,
        @PathParam("code")
        String code)
        throws Exception
    ;

    /**
     * Find all of of the care unit HSA id:s that have capacities that are expiring within the provided timeframe
     * 
     * @param withinDaysFromNow
     *     
     */
    @GET
    @Path("findexpiring/{withinDaysFromNow}")
    @Produces({
        "application/json"
    })
    CapacityService.GetCapacityFindexpiringByWithinDaysFromNowResponse getCapacityFindexpiringByWithinDaysFromNow(
        @PathParam("withinDaysFromNow")
        Long withinDaysFromNow)
        throws Exception
    ;

    public class DeleteCapacityByHsaIdByProductByCodeResponse
        extends se.sll.service.catalogue.capacity.api.support.ResponseWrapper
    {


        private DeleteCapacityByHsaIdByProductByCodeResponse(Response delegate) {
            super(delegate);
        }

        /**
         * Deletion successful.
         * 
         */
        public static CapacityService.DeleteCapacityByHsaIdByProductByCodeResponse oK() {
            Response.ResponseBuilder responseBuilder = Response.status(200);
            return new CapacityService.DeleteCapacityByHsaIdByProductByCodeResponse(responseBuilder.build());
        }

    }

    public class GetCapacityByHsaIdResponse
        extends se.sll.service.catalogue.capacity.api.support.ResponseWrapper
    {


        private GetCapacityByHsaIdResponse(Response delegate) {
            super(delegate);
        }

        /**
         * The requested capacity information was found and is returned in the body. e.g. {
         *   "hsaID": "SE2321000016-3TNL",
         *   "product": [
         *       {
         *           "capacity": [
         *               {
         *                   "code": "2",
         *                   "codeSystem": "oid.sll.vantetider",
         *                   "createdByHsaID": "CREATED",
         *                   "creationTime": 1425410281000,
         *                   "product": null,
         *                   "sourceSystemHsaID": "SOURCE",
         *                   "validTo": 1427410800000,
         *                   "value": "4"
         *               },
         *               {
         *                   "code": "1",
         *                   "codeSystem": "oid.sll.vantetider",
         *                   "createdByHsaID": "CREATED",
         *                   "creationTime": 1425410242000,
         *                   "product": null,
         *                   "sourceSystemHsaID": "SOURCE",
         *                   "validTo": 1427410800000,
         *                   "value": "16"
         *               }
         *           ],
         *           "hsaID": "SE2321000016-1HF3",
         *           "name": "40"
         *       }
         *   ]
         * 
         * 
         * @param entity
         *     {
         *       "hsaID": "SE2321000016-3TNL",
         *       "product": [
         *           {
         *               "capacity": [
         *                   {
         *                       "code": "2",
         *                       "codeSystem": "oid.sll.vantetider",
         *                       "createdByHsaID": "CREATED",
         *                       "creationTime": 1425410281000,
         *                       "product": null,
         *                       "sourceSystemHsaID": "SOURCE",
         *                       "validTo": 1427410800000,
         *                       "value": "4"
         *                   },
         *                   {
         *                       "code": "1",
         *                       "codeSystem": "oid.sll.vantetider",
         *                       "createdByHsaID": "CREATED",
         *                       "creationTime": 1425410242000,
         *                       "product": null,
         *                       "sourceSystemHsaID": "SOURCE",
         *                       "validTo": 1427410800000,
         *                       "value": "16"
         *                   }
         *               ],
         *               "hsaID": "SE2321000016-1HF3",
         *               "name": "40"
         *           }
         *       ]
         *     
         */
        public static CapacityService.GetCapacityByHsaIdResponse jsonOK(List<CareUnitRefList> entity) {
            Response.ResponseBuilder responseBuilder = Response.status(200).header("Content-Type", "application/json");
            responseBuilder.entity(entity);
            return new CapacityService.GetCapacityByHsaIdResponse(responseBuilder.build());
        }

    }

    public class GetCapacityFindexpiringByWithinDaysFromNowResponse
        extends se.sll.service.catalogue.capacity.api.support.ResponseWrapper
    {


        private GetCapacityFindexpiringByWithinDaysFromNowResponse(Response delegate) {
            super(delegate);
        }

        /**
         *  e.g. {
         *     "values": [
         *       "SE2321000016-1HF3",
         *       "SE2321000016-6Fw9"
         *     ],
         *     "empty":false
         * }
         * 
         * @param entity
         *     {
         *         "values": [
         *           "SE2321000016-1HF3",
         *           "SE2321000016-6Fw9"
         *         ],
         *         "empty":false
         *     }
         */
        public static CapacityService.GetCapacityFindexpiringByWithinDaysFromNowResponse jsonOK(UnitIds entity) {
            Response.ResponseBuilder responseBuilder = Response.status(200).header("Content-Type", "application/json");
            responseBuilder.entity(entity);
            return new CapacityService.GetCapacityFindexpiringByWithinDaysFromNowResponse(responseBuilder.build());
        }

    }

    public class GetCapacityResponse
        extends se.sll.service.catalogue.capacity.api.support.ResponseWrapper
    {


        private GetCapacityResponse(Response delegate) {
            super(delegate);
        }

        /**
         * Unknown exception in the service e.g. {
         *   "code" : "INVALID_DAYS_FROM_NOW_RANGE",
         *   "data" :
         *     {
         *       "14"
         *     }
         * }
         * 
         * 
         * @param entity
         *     {
         *       "code" : "INVALID_DAYS_FROM_NOW_RANGE",
         *       "data" :
         *         {
         *           "14"
         *         }
         *     }
         *     
         */
        public static CapacityService.GetCapacityResponse jsonInternalServerError(ServiceException entity) {
            Response.ResponseBuilder responseBuilder = Response.status(500).header("Content-Type", "application/json");
            responseBuilder.entity(entity);
            return new CapacityService.GetCapacityResponse(responseBuilder.build());
        }

        /**
         * The requested capacity information was found and is returned in the body. e.g. {
         *   "hsaID": "SE2321000016-3TNL",
         *   "product": [
         *       {
         *           "capacity": [
         *               {
         *                   "code": "2",
         *                   "codeSystem": "oid.sll.vantetider",
         *                   "createdByHsaID": "CREATED",
         *                   "creationTime": 1425410281000,
         *                   "product": null,
         *                   "sourceSystemHsaID": "SOURCE",
         *                   "validTo": 1427410800000,
         *                   "value": "4"
         *               },
         *               {
         *                   "code": "1",
         *                   "codeSystem": "oid.sll.vantetider",
         *                   "createdByHsaID": "CREATED",
         *                   "creationTime": 1425410242000,
         *                   "product": null,
         *                   "sourceSystemHsaID": "SOURCE",
         *                   "validTo": 1427410800000,
         *                   "value": "16"
         *               }
         *           ],
         *           "hsaID": "SE2321000016-1HF3",
         *           "name": "40"
         *       }
         *   ]
         * 
         * 
         * @param entity
         *     {
         *       "hsaID": "SE2321000016-3TNL",
         *       "product": [
         *           {
         *               "capacity": [
         *                   {
         *                       "code": "2",
         *                       "codeSystem": "oid.sll.vantetider",
         *                       "createdByHsaID": "CREATED",
         *                       "creationTime": 1425410281000,
         *                       "product": null,
         *                       "sourceSystemHsaID": "SOURCE",
         *                       "validTo": 1427410800000,
         *                       "value": "4"
         *                   },
         *                   {
         *                       "code": "1",
         *                       "codeSystem": "oid.sll.vantetider",
         *                       "createdByHsaID": "CREATED",
         *                       "creationTime": 1425410242000,
         *                       "product": null,
         *                       "sourceSystemHsaID": "SOURCE",
         *                       "validTo": 1427410800000,
         *                       "value": "16"
         *                   }
         *               ],
         *               "hsaID": "SE2321000016-1HF3",
         *               "name": "40"
         *           }
         *       ]
         *     
         */
        public static CapacityService.GetCapacityResponse jsonOK(List<CareUnitRefList> entity) {
            Response.ResponseBuilder responseBuilder = Response.status(200).header("Content-Type", "application/json");
            responseBuilder.entity(entity);
            return new CapacityService.GetCapacityResponse(responseBuilder.build());
        }

    }

    public class PostCapacityByunitidsResponse
        extends se.sll.service.catalogue.capacity.api.support.ResponseWrapper
    {


        private PostCapacityByunitidsResponse(Response delegate) {
            super(delegate);
        }

        /**
         * The requested capacity information was found and is returned in the body. e.g. {
         *   "hsaID": "SE2321000016-3TNL",
         *   "product": [
         *       {
         *           "capacity": [
         *               {
         *                   "code": "2",
         *                   "codeSystem": "oid.sll.vantetider",
         *                   "createdByHsaID": "CREATED",
         *                   "creationTime": 1425410281000,
         *                   "product": null,
         *                   "sourceSystemHsaID": "SOURCE",
         *                   "validTo": 1427410800000,
         *                   "value": "4"
         *               },
         *               {
         *                   "code": "1",
         *                   "codeSystem": "oid.sll.vantetider",
         *                   "createdByHsaID": "CREATED",
         *                   "creationTime": 1425410242000,
         *                   "product": null,
         *                   "sourceSystemHsaID": "SOURCE",
         *                   "validTo": 1427410800000,
         *                   "value": "16"
         *               }
         *           ],
         *           "hsaID": "SE2321000016-1HF3",
         *           "name": "40"
         *       }
         *   ]
         * 
         * 
         * @param entity
         *     {
         *       "hsaID": "SE2321000016-3TNL",
         *       "product": [
         *           {
         *               "capacity": [
         *                   {
         *                       "code": "2",
         *                       "codeSystem": "oid.sll.vantetider",
         *                       "createdByHsaID": "CREATED",
         *                       "creationTime": 1425410281000,
         *                       "product": null,
         *                       "sourceSystemHsaID": "SOURCE",
         *                       "validTo": 1427410800000,
         *                       "value": "4"
         *                   },
         *                   {
         *                       "code": "1",
         *                       "codeSystem": "oid.sll.vantetider",
         *                       "createdByHsaID": "CREATED",
         *                       "creationTime": 1425410242000,
         *                       "product": null,
         *                       "sourceSystemHsaID": "SOURCE",
         *                       "validTo": 1427410800000,
         *                       "value": "16"
         *                   }
         *               ],
         *               "hsaID": "SE2321000016-1HF3",
         *               "name": "40"
         *           }
         *       ]
         *     
         */
        public static CapacityService.PostCapacityByunitidsResponse jsonOK(List<CareUnitRefList> entity) {
            Response.ResponseBuilder responseBuilder = Response.status(200).header("Content-Type", "application/json");
            responseBuilder.entity(entity);
            return new CapacityService.PostCapacityByunitidsResponse(responseBuilder.build());
        }

    }

    public class PostCapacityResponse
        extends se.sll.service.catalogue.capacity.api.support.ResponseWrapper
    {


        private PostCapacityResponse(Response delegate) {
            super(delegate);
        }

        /**
         * Creation successful.
         * 
         */
        public static CapacityService.PostCapacityResponse created() {
            Response.ResponseBuilder responseBuilder = Response.status(201);
            return new CapacityService.PostCapacityResponse(responseBuilder.build());
        }

    }

    public class PutCapacityResponse
        extends se.sll.service.catalogue.capacity.api.support.ResponseWrapper
    {


        private PutCapacityResponse(Response delegate) {
            super(delegate);
        }

        /**
         * Update successful.
         * 
         */
        public static CapacityService.PutCapacityResponse oK() {
            Response.ResponseBuilder responseBuilder = Response.status(200);
            return new CapacityService.PutCapacityResponse(responseBuilder.build());
        }

    }

}
